package com.mtsmda.chapter6;

public class StringEx {
	
	public static void main(String[] args) {
		String s = "abcde";
		String s2 = s;
		System.out.println(s == s2);
		System.out.println(s.equals(s2));
		
		s2 = new String("abcde");
		System.out.println(s == s2);
		System.out.println(s.equals(s2));
		
		System.out.println(s2.concat("f"));
		s.concat("f");
		System.out.println("s = " + s);
		System.out.println("s2 = " + s2);
		
		System.out.println("----------------");
		String abc = "abc";
		String abcNP = new String("abc");
		System.out.println(abc.equals(abcNP));
		System.out.println(abc == abcNP);
		abcNP = new String(abc);
		System.out.println(abc.equals(abcNP));
		System.out.println(abc == abcNP);
		
		System.out.println("----------------");
		importantMethodsString();
		System.out.println("----------------");
		
	}
	
	private static void importantMethodsString(){
		String name = new String("Dmitrii");
		char last = name.charAt(name.length() - 1);
		System.out.println(last);
		
		System.out.println(name.concat(" Mynzat"));
		System.out.println(name);
		String x = "x";
		System.out.println(x + "X");
		System.out.println(x);
		String cx5 = new String("CX5");
		System.out.println(cx5 += " Mazda");
		System.out.println(cx5);
		
		System.out.println();
		
		String exit = "Exit";
		System.out.println(exit.equalsIgnoreCase("EXIT"));
		System.out.println(exit.equalsIgnoreCase("exit"));
		
		System.out.println(cx5.length());

		System.out.println();
		
		String fio = new String("Mynzat Dmitrii Aleksandrovic");
		System.out.println(fio.replace('y', 'i'));
		System.out.println(fio);
		
		System.out.println();
		
		String numbers = "0123456789";
		System.out.println(numbers.substring(5));
		System.out.println(numbers);
		System.out.println(numbers.substring(5, 7));

		System.out.println();
		
		String dima = "Dima";
		System.out.println(dima);
		System.out.println(dima.toLowerCase());
		
		System.out.println(dima.toString());
		
		String str = new String("String");
		System.out.println(str.toUpperCase());
		System.out.println(str);
		
		String trim = new String("              15                ");
		System.out.println(trim);
		System.out.println(trim.trim());
		System.out.println(trim);
	}
	
}